package com.jingnen.guess_index_server.entity;

import java.time.LocalDateTime;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.GenerationType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "guess_record")
public class GuessRecord {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @Column(name = "user_id", nullable = false)
    private Long userId;
    
    @Column(name = "guess_value", nullable = false)
    private String guessValue;

    @Column(name = "guess_time", nullable = false)
    private LocalDateTime guessTime;

    /*
     * guess_date 数据库生成列（STORED），由guess_time自动计算得到DATE(guess_time)
     * Java 实体中不需要映射此字段，由数据库生成
     */
    // 注意：该字段为生成列（GENERATED ALWAYS AS (DATE(guess_time)) STORED），
    // 无需在 Java 中定义字段

    @Column(name = "create_time", updatable = false)
    private LocalDateTime createTime;

    @Column(name = "update_time")
    private LocalDateTime updateTime;
}
